﻿using CatUtils.Utils.Currency.TextUtils;
using Microsoft.VisualBasic;
using System.Collections.Generic;

namespace CatUtils.Utils.SpecialUtils.EditHelper
{/// <summary>
/// 简繁体转换帮助
/// </summary>
    public class SimplifiedChineseToTraditional
    {
        /// <summary>
        /// 字符串简体转繁体  命名空间为： Microsoft.VisualBasic  支持自定义词库，自定义词库将会被遍历替换，替换支持正则
        /// </summary>
        /// <param name="strSimple"></param>
        /// <returns></returns>
        public static string ToTraditionalChinese(string strSimple, List<Transformation> TransformationList)
        {
            foreach (Transformation Single in TransformationList)
            {
                strSimple = TextHelper.ReplaceTextEnhance(strSimple, Single.SimplifiedChinese, Single.TraditionalChinese);
            }
            return Strings.StrConv(strSimple, VbStrConv.TraditionalChinese, 0);
        }

        /// <summary>
        /// 字符串简体转繁体  命名空间为： Microsoft.VisualBasic
        /// </summary>
        /// <param name="strSimple"></param>
        /// <returns></returns>
        public static string ToTraditionalChinese(string strSimple)
        {
            return Strings.StrConv(strSimple, VbStrConv.TraditionalChinese, 0);
        }

        /// <summary>
        /// 转换后的结构体 分为简体和繁体
        /// </summary>
        public struct Transformation
        {
            /// <summary>
            /// 简体
            /// </summary>
            public string SimplifiedChinese { get; set; }

            /// <summary>
            /// 繁体
            /// </summary>
            public string TraditionalChinese { get; set; }
        }

        /// <summary>
        /// 字符串繁体转简体 命名空间为： Microsoft.VisualBasic  支持自定义词库，自定义词库将会被遍历替换，替换支持正则
        /// </summary>
        /// <param name="strTraditional"></param>
        /// <param name="TransformationList"></param>
        /// <returns></returns>
        public static string ToSimplifiedChinese(string strTraditional, List<Transformation> TransformationList)
        {
            foreach (Transformation Single in TransformationList)
            {
                strTraditional = TextHelper.ReplaceTextEnhance(strTraditional, Single.TraditionalChinese, Single.SimplifiedChinese);
            }
            return ToSimplifiedChinese(strTraditional);
        }

        /// <summary>
        /// 字符串繁体转简体 命名空间为： Microsoft.VisualBasic
        /// </summary>
        /// <param name="strTraditional"></param>
        /// <returns></returns>
        public static string ToSimplifiedChinese(string strTraditional)
        {
            return Strings.StrConv(strTraditional, VbStrConv.SimplifiedChinese, 0);
        }
    }
}